/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.logistics.entity.ladingbill;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.base.entity.customer.Customer;
import com.jeesite.modules.base.entity.supplier.Supplier;
import com.jeesite.modules.financial.entity.arrivalreminder.ArrivalReminder;
import com.jeesite.modules.order.entity.serviceorder.ServiceOrder;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * 提单Entity
 * @author LV
 * @version 2021-03-09
 */
@Table(name="t_lading_bill", alias="a", columns={
		@Column(name="lading_bill_id", attrName="ladingBillId", label="提单ID", isPK=true),
		@Column(name="lading_bill_code", attrName="ladingBillCode", label="单据编号", queryType=QueryType.LIKE),
		@Column(name="arrival_reminder_code", attrName="arrivalReminderCode", label="到单提醒", isQuery=false),
		@Column(name="lading_bill_number", attrName="ladingBillNumber", label="提单号", queryType=QueryType.LIKE),
		@Column(name="date", attrName="date", label="提单日期"),
		@Column(name="bank_arrival_date", attrName="bankArrivalDate", label="银行到单日期"),
		@Column(name="policy_number", attrName="policyNumber", label="保单号", queryType=QueryType.LIKE),
		@Column(name="service_order_id", attrName="serviceOrderId", label="服务订单"),
		@Column(name="investor_id", attrName="investorId", label="国内资方", isQuery=false),
		@Column(name="customer_id", attrName="customerId", label="客户名称"),
		@Column(name="supplier_id", attrName="supplierId", label="供货外商", isQuery=false),
		@Column(name="foreign_businessmen_id", attrName="foreignBusinessmenId", label="外商名称", isQuery=false),
		@Column(name="payment_method", attrName="paymentMethod", label="付款方式", isQuery=false),
		@Column(name="remarks", attrName="remarks", label="备注信息", isQuery=false),
		@Column(name="transport_company", attrName="transportCompany", label="运输公司", isQuery=false),
		@Column(name="transport_method", attrName="transportMethod", label="运输方式"),
		@Column(name="from_port", attrName="fromPort", label="起运港", isQuery=false),
		@Column(name="to_port", attrName="toPort", label="目的港", isQuery=false),
		@Column(name="estimated_from_date", attrName="estimatedFromDate", label="预计起航时间"),
		@Column(name="estimated_to_date", attrName="estimatedToDate", label="预计到港时间"),
		@Column(name="actual_from_date", attrName="actualFromDate", label="实际起航时间"),
		@Column(name="actual_to_date", attrName="actualToDate", label="实际到港时间"),
		@Column(name="box_model", attrName="boxModel", label="箱型", isQuery=false),
		@Column(name="box_qty", attrName="boxQty", label="箱量", isQuery=false),
		@Column(name="box_number", attrName="boxNumber", label="箱号", isQuery=false),
		@Column(name="qty", attrName="qty", label="数量", isQuery=false),
		@Column(name="create_by", attrName="createBy", label="创建者", isUpdate=false),
		@Column(name="create_date", attrName="createDate", label="创建时间", isUpdate=false),
		@Column(name="update_by", attrName="updateBy", label="更新者", isQuery=false),
		@Column(name="update_date", attrName="updateDate", label="更新时间", isQuery=false),
	}, joinTable = {
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Customer.class, attrName = "customer", alias = "b",
                on = "b.customer_id = a.customer_id", columns = {
                @Column(name = "customer_id", label = "客户编号", isPK = true),
                @Column(name = "customer_name", label = "客户名称"),
        }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = ServiceOrder.class, attrName = "serviceOrder", alias = "c",
                on = "c.service_order_id = a.service_order_id",
                columns = {
                        @Column(name = "service_order_id", label = "服务订单ID", isPK = true),
                        @Column(name = "service_order_code", label = "服务订单编号"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Supplier.class, attrName = "supplier", alias = "d",
                on = "d.supplier_id = a.supplier_id",
                columns = {
                        @Column(name = "supplier_id", label = "供应商编号", isPK = true),
                        @Column(name = "supplier_name", label = "供应商名称"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Supplier.class, attrName = "forSupplier", alias = "e",
                on = "e.supplier_id = a.foreign_businessmen_id",
                columns = {
                        @Column(name = "supplier_id", label = "供应商编号", isPK = true),
                        @Column(name = "supplier_name", label = "供应商名称"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Supplier.class, attrName = "inSupplier", alias = "f",
                on = "f.supplier_id = a.investor_id",
                columns = {
                        @Column(name = "supplier_id", label = "供应商编号", isPK = true),
                        @Column(name = "supplier_name", label = "供应商名称"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Supplier.class, attrName = "transportSupplier", alias = "g",
                on = "g.supplier_id = a.transport_company",
                columns = {
                        @Column(name = "supplier_id", label = "供应商编号", isPK = true),
                        @Column(name = "supplier_name", label = "供应商名称"),
                }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = ArrivalReminder.class, attrName = "arrivalReminder", alias = "h",
                on = "h.arrival_reminder_id = a.arrival_reminder_code",
                columns = {
                        @Column(name = "arrival_reminder_id", label = "到单提醒id", isPK = true),
                        @Column(name = "arrival_reminder_code", label = "到单提醒编号"),
                }),
}, orderBy="a.update_date DESC"
)
public class LadingBill extends DataEntity<LadingBill> {
	
	private static final long serialVersionUID = 1L;
	private String ladingBillId;		// 提单ID
	private String ladingBillCode;		// 单据编号
	private String arrivalReminderCode;		// 到单提醒
	private ArrivalReminder arrivalReminder;
	private String ladingBillNumber;		// 提单号
	private Date date;		// 提单日期
	private Date bankArrivalDate;		// 银行到单日期
	private String policyNumber;		// 保单号
	private String serviceOrderId;		// 服务订单
	private ServiceOrder serviceOrder;
	private String investorId;		// 国内资方
    private Supplier inSupplier;
	private String customerId;		// 客户名称
    private Customer customer;
	private String supplierId;		// 供货外商
    private Supplier supplier;
	private String foreignBusinessmenId;		// 外商名称
    private Supplier forSupplier;
	private String paymentMethod;		// 付款方式
	private String transportCompany;		// 运输公司
    private Supplier transportSupplier;
	private String transportMethod;		// 运输方式
	private String fromPort;		// 起运港
	private String toPort;		// 目的港
	private Date estimatedFromDate;		// 预计起航时间
	private Date estimatedToDate;		// 预计到港时间
	private Date actualFromDate;		// 实际起航时间
	private Date actualToDate;		// 实际到港时间
	private String boxModel;		// 箱型
	private String boxQty;		// 箱量
	private String boxNumber;		// 箱号
	private Long qty;		// 数量
	private List<LadingBillDetail> ladingBillDetailList = ListUtils.newArrayList();		// 子表列表
	
	public LadingBill() {
		this(null);
	}

	public LadingBill(String id){
		super(id);
	}
	
	public String getLadingBillId() {
		return ladingBillId;
	}

	public void setLadingBillId(String ladingBillId) {
		this.ladingBillId = ladingBillId;
	}
	
	@Length(min=0, max=100, message="单据编号长度不能超过 100 个字符")
	public String getLadingBillCode() {
		return ladingBillCode;
	}

	public void setLadingBillCode(String ladingBillCode) {
		this.ladingBillCode = ladingBillCode;
	}
	
	@Length(min=0, max=100, message="到单提醒长度不能超过 100 个字符")
	public String getArrivalReminderCode() {
		return arrivalReminderCode;
	}

	public void setArrivalReminderCode(String arrivalReminderCode) {
		this.arrivalReminderCode = arrivalReminderCode;
	}
	
	@NotBlank(message="提单号不能为空")
	@Length(min=0, max=100, message="提单号长度不能超过 100 个字符")
	public String getLadingBillNumber() {
		return ladingBillNumber;
	}

	public void setLadingBillNumber(String ladingBillNumber) {
		this.ladingBillNumber = ladingBillNumber;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	public Date getBankArrivalDate() {
		return bankArrivalDate;
	}

	public void setBankArrivalDate(Date bankArrivalDate) {
		this.bankArrivalDate = bankArrivalDate;
	}
	
	@Length(min=0, max=100, message="保单号长度不能超过 100 个字符")
	public String getPolicyNumber() {
		return policyNumber;
	}

	public void setPolicyNumber(String policyNumber) {
		this.policyNumber = policyNumber;
	}
	
	@Length(min=0, max=64, message="服务订单长度不能超过 64 个字符")
	public String getServiceOrderId() {
		return serviceOrderId;
	}

	public void setServiceOrderId(String serviceOrderId) {
		this.serviceOrderId = serviceOrderId;
	}
	
	@Length(min=0, max=64, message="国内资方长度不能超过 64 个字符")
	public String getInvestorId() {
		return investorId;
	}

	public void setInvestorId(String investorId) {
		this.investorId = investorId;
	}
	
	@Length(min=0, max=64, message="客户名称长度不能超过 64 个字符")
	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}
	
	@Length(min=0, max=64, message="供货外商长度不能超过 64 个字符")
	public String getSupplierId() {
		return supplierId;
	}

	public void setSupplierId(String supplierId) {
		this.supplierId = supplierId;
	}
	
	@Length(min=0, max=64, message="外商名称长度不能超过 64 个字符")
	public String getForeignBusinessmenId() {
		return foreignBusinessmenId;
	}

	public void setForeignBusinessmenId(String foreignBusinessmenId) {
		this.foreignBusinessmenId = foreignBusinessmenId;
	}
	
	@Length(min=0, max=2, message="付款方式长度不能超过 2 个字符")
	public String getPaymentMethod() {
		return paymentMethod;
	}

	public void setPaymentMethod(String paymentMethod) {
		this.paymentMethod = paymentMethod;
	}
	
	@NotBlank(message="运输公司不能为空")
	@Length(min=0, max=64, message="运输公司长度不能超过 64 个字符")
	public String getTransportCompany() {
		return transportCompany;
	}

	public void setTransportCompany(String transportCompany) {
		this.transportCompany = transportCompany;
	}
	
	@Length(min=0, max=2, message="运输方式长度不能超过 2 个字符")
	public String getTransportMethod() {
		return transportMethod;
	}

	public void setTransportMethod(String transportMethod) {
		this.transportMethod = transportMethod;
	}
	
	@Length(min=0, max=2, message="起运港长度不能超过 2 个字符")
	public String getFromPort() {
		return fromPort;
	}

	public void setFromPort(String fromPort) {
		this.fromPort = fromPort;
	}
	
	@Length(min=0, max=2, message="目的港长度不能超过 2 个字符")
	public String getToPort() {
		return toPort;
	}

	public void setToPort(String toPort) {
		this.toPort = toPort;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	@NotNull(message="预计起航时间不能为空")
	public Date getEstimatedFromDate() {
		return estimatedFromDate;
	}

	public void setEstimatedFromDate(Date estimatedFromDate) {
		this.estimatedFromDate = estimatedFromDate;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	@NotNull(message="预计到港时间不能为空")
	public Date getEstimatedToDate() {
		return estimatedToDate;
	}

	public void setEstimatedToDate(Date estimatedToDate) {
		this.estimatedToDate = estimatedToDate;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	public Date getActualFromDate() {
		return actualFromDate;
	}

	public void setActualFromDate(Date actualFromDate) {
		this.actualFromDate = actualFromDate;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	public Date getActualToDate() {
		return actualToDate;
	}

	public void setActualToDate(Date actualToDate) {
		this.actualToDate = actualToDate;
	}
	
	@Length(min=0, max=100, message="箱型长度不能超过 100 个字符")
	public String getBoxModel() {
		return boxModel;
	}

	public void setBoxModel(String boxModel) {
		this.boxModel = boxModel;
	}
	
	@Length(min=0, max=100, message="箱量长度不能超过 100 个字符")
	public String getBoxQty() {
		return boxQty;
	}

	public void setBoxQty(String boxQty) {
		this.boxQty = boxQty;
	}
	
	@Length(min=0, max=100, message="箱号长度不能超过 100 个字符")
	public String getBoxNumber() {
		return boxNumber;
	}

	public void setBoxNumber(String boxNumber) {
		this.boxNumber = boxNumber;
	}
	
	public Long getQty() {
		return qty;
	}

	public void setQty(Long qty) {
		this.qty = qty;
	}
	
	public Date getDate_gte() {
		return sqlMap.getWhere().getValue("date", QueryType.GTE);
	}

	public void setDate_gte(Date date) {
		sqlMap.getWhere().and("date", QueryType.GTE, date);
	}
	
	public Date getDate_lte() {
		return sqlMap.getWhere().getValue("date", QueryType.LTE);
	}

	public void setDate_lte(Date date) {
		sqlMap.getWhere().and("date", QueryType.LTE, date);
	}
	
	public Date getBankArrivalDate_gte() {
		return sqlMap.getWhere().getValue("bank_arrival_date", QueryType.GTE);
	}

	public void setBankArrivalDate_gte(Date bankArrivalDate) {
		sqlMap.getWhere().and("bank_arrival_date", QueryType.GTE, bankArrivalDate);
	}
	
	public Date getBankArrivalDate_lte() {
		return sqlMap.getWhere().getValue("bank_arrival_date", QueryType.LTE);
	}

	public void setBankArrivalDate_lte(Date bankArrivalDate) {
		sqlMap.getWhere().and("bank_arrival_date", QueryType.LTE, bankArrivalDate);
	}
	
	public Date getEstimatedFromDate_gte() {
		return sqlMap.getWhere().getValue("estimated_from_date", QueryType.GTE);
	}

	public void setEstimatedFromDate_gte(Date estimatedFromDate) {
		sqlMap.getWhere().and("estimated_from_date", QueryType.GTE, estimatedFromDate);
	}
	
	public Date getEstimatedFromDate_lte() {
		return sqlMap.getWhere().getValue("estimated_from_date", QueryType.LTE);
	}

	public void setEstimatedFromDate_lte(Date estimatedFromDate) {
		sqlMap.getWhere().and("estimated_from_date", QueryType.LTE, estimatedFromDate);
	}
	
	public Date getEstimatedToDate_gte() {
		return sqlMap.getWhere().getValue("estimated_to_date", QueryType.GTE);
	}

	public void setEstimatedToDate_gte(Date estimatedToDate) {
		sqlMap.getWhere().and("estimated_to_date", QueryType.GTE, estimatedToDate);
	}
	
	public Date getEstimatedToDate_lte() {
		return sqlMap.getWhere().getValue("estimated_to_date", QueryType.LTE);
	}

	public void setEstimatedToDate_lte(Date estimatedToDate) {
		sqlMap.getWhere().and("estimated_to_date", QueryType.LTE, estimatedToDate);
	}
	
	public Date getActualFromDate_gte() {
		return sqlMap.getWhere().getValue("actual_from_date", QueryType.GTE);
	}

	public void setActualFromDate_gte(Date actualFromDate) {
		sqlMap.getWhere().and("actual_from_date", QueryType.GTE, actualFromDate);
	}
	
	public Date getActualFromDate_lte() {
		return sqlMap.getWhere().getValue("actual_from_date", QueryType.LTE);
	}

	public void setActualFromDate_lte(Date actualFromDate) {
		sqlMap.getWhere().and("actual_from_date", QueryType.LTE, actualFromDate);
	}
	
	public Date getActualToDate_gte() {
		return sqlMap.getWhere().getValue("actual_to_date", QueryType.GTE);
	}

	public void setActualToDate_gte(Date actualToDate) {
		sqlMap.getWhere().and("actual_to_date", QueryType.GTE, actualToDate);
	}
	
	public Date getActualToDate_lte() {
		return sqlMap.getWhere().getValue("actual_to_date", QueryType.LTE);
	}

	public void setActualToDate_lte(Date actualToDate) {
		sqlMap.getWhere().and("actual_to_date", QueryType.LTE, actualToDate);
	}
	
	public Date getCreateDate_gte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
	}

	public void setCreateDate_gte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
	}
	
	public Date getCreateDate_lte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
	}

	public void setCreateDate_lte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
	}
	
	public List<LadingBillDetail> getLadingBillDetailList() {
		return ladingBillDetailList;
	}

	public void setLadingBillDetailList(List<LadingBillDetail> ladingBillDetailList) {
		this.ladingBillDetailList = ladingBillDetailList;
	}

    public ArrivalReminder getArrivalReminder() {
        return arrivalReminder;
    }

    public void setArrivalReminder(ArrivalReminder arrivalReminder) {
        this.arrivalReminder = arrivalReminder;
    }

    public ServiceOrder getServiceOrder() {
        return serviceOrder;
    }

    public void setServiceOrder(ServiceOrder serviceOrder) {
        this.serviceOrder = serviceOrder;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public Supplier getForSupplier() {
        return forSupplier;
    }

    public void setForSupplier(Supplier forSupplier) {
        this.forSupplier = forSupplier;
    }

    public Supplier getInSupplier() {
        return inSupplier;
    }

    public void setInSupplier(Supplier inSupplier) {
        this.inSupplier = inSupplier;
    }

    public Supplier getSupplier() {
        return supplier;
    }

    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    public Supplier getTransportSupplier() {
        return transportSupplier;
    }

    public void setTransportSupplier(Supplier transportSupplier) {
        this.transportSupplier = transportSupplier;
    }
}